package com.example.JavaDemo.Controller;



import com.example.JavaDemo.domain.Building;
import com.example.JavaDemo.domain.Community;
import com.example.JavaDemo.service.IBuildingService;
import com.example.comon.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import java.util.List;

/**
 * 接口文档访问地址 http://127.0.0.1:8089/swagger-ui/index.html
 * apifox 导入接口数据 http://127.0.0.1:8089/v2/api-docs
 */

@RestController
@RequestMapping("/building")
@Api(value = "building",tags = "楼栋管理")
public class BuildingController {
    @Autowired
    private IBuildingService buildingService;

    @GetMapping("/getBuildingList")
    @ApiOperation("查询楼栋")
    public R<List<Building>> getBuildingList(Building building){
        List<Building> list = buildingService.selectBuilding(building);
        return R.success(list);    }

    @PostMapping("/addBuilding")
    @ApiOperation("增加楼栋")
    public R<Building> addBuilding(@RequestBody Building building){
        buildingService.insertBuilding(building);
        return R.success(building);
    }

    @PostMapping("/updateBuildingById")
    @ApiOperation("修改楼栋")
    public R<List<Community>> updateBuildingById(@RequestBody Building building){
        buildingService.updateBuildingById(building);
        return R.success();
    }

    @DeleteMapping("/delBuildingById")
    @ApiOperation("删除楼栋")
    public R<List<Community>> delBuildingById (String id){
        buildingService.delBuildingById(id);
        return  R.success();
    }
}
